import { Scene } from "../../../../../Core/Module/Entity/Scene";
import { SceneType } from "../../../../../Core/Module/Entity/SceneType";
import { ActorMessageHandlerAttribute } from "../../../../../Decorator/Decorator";
import { ObjectAddRequest, ObjectAddResponse } from "../../../../Model/Generate/Share/Message/InnerMessage_S_20001";
import { LocationComponent } from "../../../../Model/Server/Module/ActorLocation/LocationComponent";
import { AMActorRpcHandler } from "../Actor/AMActorRpcHandler";

@ActorMessageHandlerAttribute(SceneType.Location, ObjectAddRequest, ObjectAddResponse)
export class ObjectAddRequestHandler extends AMActorRpcHandler<Scene, ObjectAddRequest, ObjectAddResponse> {

    protected override async Run(scene: Scene, request: ObjectAddRequest, response: ObjectAddResponse): Promise<void> {
        await scene.GetComponent<LocationComponent>(LocationComponent).Add(request.Key, request.InstanceId);
    }

}